Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support empty string OpenAPI identifiers #59

Merged
merged 2 commits into from
Jun 11, 2023

Conversation

simonjbeaumont
Copy link
Collaborator

Motivation

The OpenAPI specification allows the use of the empty string in some places, for example in the following enum, which we've seen in some real-world OpenAPI documents:

type: string
enum:
  - ""
  - foo
  - bar

We have code that converts an OpenAPI identifier to a suitable string that can be used as a Swift identifier. It currently returns an empty string when given an empty string as input, which is not a valid Swift identifier. We already have some logic there to avoid clashing with some Swift keywords, so this can be extended to handle the empty string.

Modifications

  • Map the empty string OpenAPI identifier to "_empty"

Result

We can generate compiling code when presented with empty string OpenAPI identifiers.

Test Plan

  • Added unit test.
  • Extended reference test.

Resolves

Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

Signed-off-by: Si Beaumont <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty string enum value breaks the generator
2 participants